#ifndef ____________________WARD_TRANSITMGR_CPP
#define ____________________WARD_TRANSITMGR_CPP


#include "transitMgr.h"
#include "transitInfo.h"

//adds a transit to the list
void transitMgr::add(int src, int dest, int turns, Force f)
{
transitInfo n(src, dest, turns, f);
data.push_back(n);
current = data.end();
ncptr = data.begin();
}

//returns true if there are more finished transits
bool transitMgr::moreDone()
{
	std::list<transitInfo>::iterator i = data.begin();
	for(; i != data.end(); i++)
		if(i->arrived())
			return true;

return false;
}

//returns true if there ar emore finished transits, AND loads the next one into the "current" pointer which
//can be used with the accessors below.
//returns false if there are no more finished transits
bool transitMgr::nextDone()
{
	if(current != data.end())
	{
		data.erase(current);
		current = data.end();
		ncptr = data.begin();
	}
	std::list<transitInfo>::iterator i = data.begin();
	for(; i != data.end(); i++)
		if(i->arrived())
		{
			current = i;
			return true;
			break;
		}


return false;
}


list<transitInfo>& transitMgr::getList()
{

	return data;

}

void transitMgr::turn()
{

	std::list<transitInfo>::iterator i = data.begin();
	ncptr = data.begin();
	for(; i != data.end(); i++)
		i->turn();



}

void transitMgr::turn(int loc)
{
	ncptr = data.begin();
	current = data.end();
	std::list<transitInfo>::iterator i = data.begin();
	for(; i != data.end(); i++)
		if(i->getForce().getOwner() == loc)
			i->turn();

}


void transitMgr::print()
{
	cout << "Src: " << current->getSrc() << "\t" << "Dst: " << current->getDest() << "\t" << "Turns: " << current->getTurns() << "\t" << "Troops: " << current->getForce().getSize() << endl; 
}

#endif